'use strict';
const db = uniCloud.database();
const dbCmd = db.command // 取指令

async function purchaseDetail(event){
	console.log(event)
	let { id } = event , result = {}
	await db.collection('order')
	.aggregate()
	.match({_id: id})
	.lookup({
    from: 'uni-id-users',
    localField: 'uid',
    foreignField: '_id',
    as: 'userList',
  })
	.lookup({
	  from: 'xinxuan_hotel',
	  localField: 'hotel_id',
	  foreignField: '_id',
	  as: 'hotelList',
	})
  .end()
	.then((res)=>{
		result = res.data[0]
		console.log(res.data[0])
	})
	
	return {
		code: 0,
		data: result
	}
}

exports.main = purchaseDetail;